/**
 * Copyright (C), 2015-2024, XXX有限公司
 * FileName: HelloController
 * Author:   zr
 * Date:     2024/10/28 23:50
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.itheima.demo1.controller;

import com.itheima.demo1.service.GreetingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 〈一句话功能简述〉<br> 
 * 〈〉
 *
 * @author zr
 * @create 2024/10/28
 * @since 1.0.0
 */
@RestController
/*让它作为控制器，处理http请求*/
@RequestMapping("/api")
/*将控制器的方法映射到api路径上。类级别路径*/
public class GreetingController {
 private final GreetingService greetingService;
 /*使用SLF4J日志框架创建一个Logger对象，用于记录日志的信息，尤其是类级别的日志*/
 private static final Logger logger= LoggerFactory.getLogger(GreetingController.class);
 @Autowired
 public GreetingController(GreetingService greetingService) {
  this.greetingService = greetingService;
 }
@GetMapping("/greeting")
    public String greeting(){
     logger.info("Handing /greeting request");
     return greetingService.getMessage();
}
}
